#ifndef PROTOCOL_H
#define PROTOCOL_H

#include <QObject>

namespace Protocol
{

const quint8 E_PACKV1_HEAD = 0x06; //!< 包头
const quint8 E_PACKV1_TAIL = 0x60; //!< 包尾
const quint8 E_PACKV1_NEED_FEEDBACK = 0x01; //!< 需要应答
const quint8 E_PACKV1_NOT_FEEDBACK  = 0x00; //!< 不需要应答
const quint8 E_PACKV1_DEVICE_ADDRESS = 0x01; //!< 设备地址
const quint8 E_PACKV1_MIN_LENGTH = 0x0A;  //!< 当个包最小长度

const int  E_TIMEOUT = 5000;  //!< 超时重发

inline static quint8 check_sum(const quint8 *buffer, quint8 number)
{
    int i,Temp=0;
    for(i=0;i<number;i++)
    {
        Temp+=buffer[i];
    }
    return 256-(Temp&0xff);
}

//!
//! \brif 包命令
//!
enum E_PACKV1
{
    E_PACKV1_SHAKEHAND = 0,       //!< 握手包*@
    E_PACKV1_FEEDBACK,            //!< 反馈包@
    E_PACKV1_TEMPERATURE,         //!< 温度@
    E_PACKV1_ADJUSTED_VALUE,              //!<
    E_PACKV1_MAX
};

//!
//! \brief 设备类型
//!
enum E_PACKV1_DEVICETYPE_TYPE
{
    E_PACKV1_DEVICETYPE_BROADCAST, //!< 广播设备
    E_PACKV1_TOUCH_SCREEN,         //!< 触摸屏(触摸屏上位机)
    E_PACKV1_DEVICETYPE_HOST,      //!< 主机(下位机)
    E_PACKV1_WLC, 		           //!< 无线终端控制器(终端上位机)
    E_PACKV1_DEVICETYPE_MAX
};

enum E_PACKV1_SHAKEHAND_TYPE
{
    E_PACKV1_TYPE_V1 = 1, //!< 协议1
    E_PACKV1_TYPE_MAX
};

} // namespace

#endif // PROTOCOL_H
